.pragma library
Qt.include("Constants.js")

//Utility function to convert 2d board coordinates to 1d array index
function index(col, row) {
    if (col >= 0 && row >= 0 && col < maxCol && row < maxRow){
        return col + (row * maxCol);
    } else {
        return -1
    }
}
//Utility Function, reverse to index()
function xFromIndex(index){
    return index % maxCol
}
//Utility Function, reverse to index()
function yFromIndex(index){
    return Math.floor(index / maxCol)
}
